package com.liveinstars.activity.business.activity.service.impl;

import com.baidu.unbiz.easymapper.MapperFactory;
import com.liveinstars.activity.business.activity.repository.po.Question;
import com.liveinstars.api.dto.QuestionDto;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 进行po和实体的转换，和event的生成等工作
 */
@Service
public class QuestionFactory {
    public List<QuestionDto> getQuestionsDto(List<Question> questions) {
        MapperFactory.getCopyByRefMapper().mapClass(Question.class, QuestionDto.class).register();
        List<QuestionDto> questionDtos = questions.stream().map(p -> MapperFactory.getCopyByRefMapper().map(p,
                QuestionDto.class)).collect(Collectors.toList());
        return questionDtos;
    }
}
